var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("GameEm"),
    p = cc._decorator,
    l = p.ccclass,
    d = p.property,
    u =
        (p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.type = 1;
                return e;
            }
            e.prototype.checkBtnView = function () {
                var t = GameDataValue.getWearEquip(this.type + "");
                if (t) {
                    this._viewNode.active = !0;
                    var e = GameDataValue.getEquipData(t),
                        o = CacheDataManager.getCostumeup()[e.id],
                        a = CacheDataManager.getCostumeLvData(o.quality, e.lv);
                    if ("-1" == a.up_diamond) {
                        this._viewNode.active = !1;
                        return;
                    }
                    var i = a.up_diamond || 0;
                    i = Math.max(Math.floor(i), 0);
                    this._cost.$Label.string = i + "";
                    this._revenue.$Label.string = "+" + CacheDataManager.getQualityLevelAdd(o.quality, e.lv) + "%";
                } else this._viewNode.active = !1;
            };
            e.prototype.onLoad = function () {
                EVUIEffView.on(EVUIEffView.checkCostUI, this.checkBtnView.bind(this), this);
                this.checkBtnView();
            };
            e.prototype.onDestroy = function () {
                EVUIEffView.offTarget(this);
            };
            e.prototype._onTouchEnd = function () {
                this.updateLv();
            };
            e.prototype.updateLv = function () {
                var t = this;
                if (this._viewNode.active) {
                    QAudio.play(QAudio.ui_button);
                    var e = GameDataValue.getWearEquip(this.type + ""),
                        o = GameDataValue.getEquipData(e),
                        a = CacheDataManager.getCostumeup()[o.id],
                        i = CacheDataManager.getCostumeLvData(a.quality, o.lv).up_diamond || 0;
                    i = Math.max(Math.floor(i), 0);
                    var n = GameDataValue.getPropCount(c.PropKind.zhuanshi);
                    n >= i && i > 0
                        ? s.default.open(r.UIID.UIUseZs, {
                              cost: i,
                              cb: function () {
                                  GameDataValue.upExpEquip(e);
                                  GameDataValue.setPropCount(c.PropKind.zhuanshi, n - i);
                                  CacheDataManager.updateCostDataView = !0;
                                  t.checkBtnView();
                                  var a = {resId: "" + o.id, count: i, type: 1, tip: "装备升级", tip2: ""};
                                  PayData.addLog(a.resId, a.count, a.type, [], a.tip, a.tip2);
                              }
                          })
                        : s.default.open(r.UIID.UIToast, {msg: "钻石不足"});
                    CacheDataManager.updateCostDataView = !0;
                }
            };
            n([d()], e.prototype, "type", void 0);
            return n([l], e);
        })(Thor));
o.default = u;
